package com.zhj.interview;

public class Test15 {

    public static void main(String[] args) {
        User ZhangSan = new User("张三");
        User LiSi = new User("李四");
        System.out.println("开始交换---------------------------------");
        swap(ZhangSan, LiSi);
        System.out.println("交换结束---------------------------------");
        System.out.println("交换后ZhangSan的名字：" + ZhangSan.name);
        System.out.println("交换后LiSi的名字：" + LiSi.name);
    }

    private static void swap(User ZhangSan, User LiSi){
        User user;
        user = ZhangSan;
        ZhangSan = LiSi;
        LiSi = user;
        System.out.println("交换后ZhangSan的名字：" + ZhangSan.name);
        System.out.println("交换后LiSi的名字：" + LiSi.name);
    }
}
class User{
    String name;
    User(String name) {
        this.name = name;
    }
}
